<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <style>
        html,
        body,
        #mapui {
            margin: 0 auto;
            width: 100%;
            height: 100%
        }

        html,
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
        }
    </style>

</head>

<body>
    <div id="mapui"></div>

    <script src="./js_thematic_map_example/script/jq/jquery.min.js"></script>
    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>
    

    <script>
        var echartslayer = null;
        var resources = {
            "text_weiboChina": "",
            "text_strong": "强",
            "text_middle": "中",
            "text_weak": "弱",
        }
        var option = null;
        var amap = null;
        var that = this;

        $.get('./js_thematic_map_example/data/echarts-weibo.json', function (weiboData) {
            console.log(weiboData)
            weiboData = weiboData.map(function (serieData, idx) {
                var px = serieData[0] / 1000;
                var py = serieData[1] / 1000;
                var res = [
                    [px, py]
                ];

                for (var i = 2; i < serieData.length; i += 2) {
                    var dx = serieData[i] / 1000;
                    var dy = serieData[i + 1] / 1000;
                    var x = px + dx;
                    var y = py + dy;
                    res.push([x.toFixed(2), y.toFixed(2), 1]);

                    px = x;
                    py = y;
                }
                return res;
            });

            option = {
                GLMap: {
                    roam: true
                },
                coordinateSystem: 'GLMap',
                title: {
                    text: resources.text_weiboChina,
                    subtext: '',
                    sublink: 'http://www.thinkgis.cn/public/sina',
                    left: 'center',
                    top: 'top',
                    textStyle: {
                        color: '#DC143C'
                    }
                },
                tooltip: {},
                legend: {
                    left: 'left',
                    top: 'bottom',
                    data: [resources.text_strong, resources.text_middle, resources.text_weak],
                    textStyle: {
                        color: '#ccc'
                    }
                },
                geo: {
                    name: resources.text_strong,
                    type: 'scatter',
                    map: 'GLMap',
                    label: {
                        emphasis: {
                            show: false
                        }
                    },
                    itemStyle: {
                        normal: {
                            areaColor: '#323c48',
                            borderColor: '#111'
                        },
                        emphasis: {
                            areaColor: '#2a333d'
                        }
                    }
                },
                series: [{
                    name: resources.text_weak,
                    type: 'scatter',
                    coordinateSystem: 'GLMap',
                    symbolSize: 1,
                    large: true,
                    itemStyle: {
                        normal: {
                            shadowBlur: 2,
                            shadowColor: 'rgba(37, 140, 249, 0.8)',
                            color: 'rgba(37, 140, 249, 0.8)'
                        }
                    },
                    data: weiboData[0]
                }, {
                    name: resources.text_middle,
                    type: 'scatter',
                    coordinateSystem: 'GLMap',
                    symbolSize: 1,
                    large: true,
                    itemStyle: {
                        normal: {
                            shadowBlur: 2,
                            shadowColor: 'rgba(14, 241, 242, 0.8)',
                            color: 'rgba(14, 241, 242, 0.8)'
                        }
                    },
                    data: weiboData[1]
                }, {
                    name: resources.text_strong,
                    type: 'scatter',
                    coordinateSystem: 'GLMap',
                    symbolSize: 1,
                    large: true,
                    itemStyle: {
                        normal: {
                            shadowBlur: 2,
                            shadowColor: 'rgba(255, 255, 255, 0.8)',
                            color: 'rgba(255, 255, 255, 0.8)'
                        }
                    },
                    data: weiboData[2]
                }]
            }

            map.Factory.create('mapui', {
                style:style,
                center: [112, 37.94],
                fullExtent: {
                    xmin: 90.992204,
                    ymin: 10.979711,
                    xmax: 120.5338915,
                    ymax: 50.543712
                },
                zoom: 3,
                projection: 'EPSG:4326',
                strategy: ['mapboxgl', 'openlayers']
            }, (o) => {
                amap = o;
                map.Factory.loadSpecialMap('echarts', () => {
                that.init(amap.pmap);
            })
            });

        });


        function init(map) {
            echartslayer = new EchartsLayer(map);
            echartslayer.chart.setOption(option);
        }



    </script>
</body>

</html>